<?php

namespace app\mobile\controller;

use think\Controller;
use think\Db;
use think\Session;

class Login extends Controller
{
    public function index()
    {
        return view('login/index');
    }

    public function login()
    {
        $list = Db::name('huser')->where(['email' => input('post.email'),'userpass'=>md5(input('post.pwd'))])->find();

        if ($list > 0) {
            Session::set('id',$list['id']);
//             Session::set('homeemail',input('post.email'));
            return $this->success('登录成功', url('mobile/index/index'));
        } else {
            return $this->error('登录失败');
        }
        return view('index/index');
    }

    public function zhuxiao()
    {
        Session::delete('homeemail','think');
        Session::delete('id','think');

        if(Session::get('id')==null){
          return $this->success('注销成功','mobile/index/index');
        }else{
            return $this->error('注销失败');
        }

    }
}
